﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using CultuRAM.Models;
using PagedList;
using WebGrease.Css.Extensions;
using WebMatrix.WebData;

namespace CultuRAM.DAL
{
    public class CultuRAMInitializer : DropCreateDatabaseAlways<CultuRAMContext>
    //public class CultuRAMInitializer : CreateDatabaseIfNotExists<CultuRAMContext>
    {
        protected override void Seed(CultuRAMContext context)
        {
            

            WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "Email", autoCreateTables: true);

            #region ENTITIES

            var cities = new List<City>
                {
                    new City() {CityName = "Calheta"},
                    new City() {CityName = "Câmara de Lobos"},
                    new City() {CityName = "Funchal"},
                    new City() {CityName = "Machico"},
                    new City() {CityName = "Santa Cruz"},          
                    new City() {CityName = "Santana"},
                    new City() {CityName = "São Vicente"},
                    new City() {CityName = "Ponta do Sol"},
                    new City() {CityName = "Porto Moniz"},
                    new City() {CityName = "Porto Santo"},
                    new City() {CityName = "Ribeira Brava"}
                    
                };
            cities.ForEach(c => context.Cities.Add(c));
            context.SaveChanges();

            var entityTypes = new List<EntityType>
                {
                    new EntityType() {EntityTypeName = "Promotora de Eventos"},
                    new EntityType() {EntityTypeName = "Gestora de Espaços Culturais"},
                    new EntityType() {EntityTypeName = "Promotora de Eventos e Gestora de Espaços Culturais"},
                    new EntityType() {EntityTypeName = "Privada"},
                    new EntityType() {EntityTypeName = "Pública"},
                    new EntityType() {EntityTypeName = "Associação"},
                    new EntityType() {EntityTypeName = "Fundação"},
                };
            entityTypes.ForEach(et => context.EntityTypes.Add(et));
            context.SaveChanges();

            var entities = new List<Entity>
                {
                    new Entity() {Name = "Direção Regional dos Assuntos Culturais", Responsible = "Marisa Santos" , Email = "msantos@drac.pt", ResponsibleContact = "msantos@drac.pt", City = cities[2], EntityType = entityTypes[2]},
                    new Entity() {Name = "Direção de Serviços de Educação Artística e Multimédia", Responsible = "João Borges" ,  Email = "g.dseam@gmail.com", ResponsibleContact = "962233444",City = cities[2], EntityType = entityTypes[1]},
                    new Entity() {Name = "Associação Recreio Musical União da Mocidade", Responsible = "Eurico Martins" , Email = "e.martins@gmail.com",  ResponsibleContact = "291334455",City = cities[2], EntityType = entityTypes[1]},
                    new Entity() {Name = "Conservatório - Escola de Artes da Madeira", Responsible = "Tomásia ALves" ,  Email = "tomasialves@gmail.com", ResponsibleContact = "tomasialves@gmail.com",City = cities[2], EntityType = entityTypes[1]},
                    new Entity() {Name = "Associação Notas e Sinfonias do Atlântico",Responsible = "Tomásia ALves" ,  Email = "tomasialves@gmail.com", ResponsibleContact = "tomasialves@gmail.com", City = cities[2], EntityType = entityTypes[1]},
                    new Entity() {Name = "Associação Xarabanda", Responsible = "Rui Camacho" ,  Email = "ruicamacho@gmail.com", ResponsibleContact = "ruicamacho@gmail.com", City = cities[4], EntityType = entityTypes[1]},
                    new Entity() {Name = "Grupo Pestana", Responsible = "Gonçalo Abreu" ,  Email = "gabreu@pestan.pt", ResponsibleContact = "gabreu@pestan.pt",City = cities[2], EntityType = entityTypes[2]},
                    new Entity() {Name = "Deltasom",Responsible = "Luís Nunes" ,  Email = "luis.nunes@gmail.com", ResponsibleContact = "luis.nunes@gmail.com", City = cities[1], EntityType = entityTypes[3]},
                    new Entity() {Name = "Direção Regional de Turismo",  Email = "pfonseca@gov-madeira.pt", Responsible = "Pedro Fonseca" , ResponsibleContact = "pfonseca@gov-madeira.pt", City = cities[2], EntityType = entityTypes[4]},  
                    new Entity() {Name = "Madeira Tecnopolo",  Email = "apimenta@mt.pt", Responsible = "Atónio Pimenta" , ResponsibleContact = "apimenta@mt.pt", City = cities[0], EntityType = entityTypes[1]},
                    new Entity() {Name = "Câmara Municipal do Funchal",  Email = "gmota@cmf.pt", Responsible = "Graça Mota" , ResponsibleContact = "gmota@cmf.pt", City = cities[0], EntityType = entityTypes[2]},
                    new Entity() {Name = "Centro Cívico do Estreito de Câmara de Lobos",  Email = "pmacedo@ccec.pt", Responsible = "Paulo Macedo" , ResponsibleContact = "pmacedo@ccec.pt", City = cities[1], EntityType = entityTypes[2]},
                    new Entity() {Name = "Universidade da Madeira", Responsible = "Isabel Gomes" ,  Email = "mpires@reids.pt", ResponsibleContact = "isabelg@uma.pt", City = cities[0], EntityType = entityTypes[2]},
                    new Entity() {Name = "Reids Palace Hotel", Responsible = "Manuel Pires" ,  Email = "mpires@reids.pt", ResponsibleContact = "mpires@reids.pt", City = cities[0], EntityType = entityTypes[3]},
                    new Entity() {Name = "Malo Clinic", Responsible = "Pedro Malo" ,  Email = "pmalo@malo.pt", ResponsibleContact = "pmalo@malo.pt", City = cities[0], EntityType = entityTypes[4]},
                    new Entity() {Name = "Museu Etnográfico da Madeira", Responsible = "Rita Faria" ,  Email = "rita@mem.pt", ResponsibleContact = "rita@mem.pt", City = cities[0], EntityType = entityTypes[2]},
                    new Entity() {Name = "Museu de Imprensa da Madeira", Responsible = "Geral" ,  Email = "geral@mim.pt", ResponsibleContact = "geral@mim.pt", City = cities[1], EntityType = entityTypes[2]},
                    new Entity() {Name = "Madeirashopping", Responsible = "Geral" ,  Email = "geral@madeirashopping.pt", ResponsibleContact = "geral@madeirashopping.pt", City = cities[0], EntityType = entityTypes[4]},
                    new Entity() {Name = "Café do Teatro", Responsible = "Rui Trindade" ,  Email = "rui@cafeteatro.pt", ResponsibleContact = "rui@cafeteatro.pt", City = cities[0], EntityType = entityTypes[3]},
                    new Entity() {Name = "Hotel Four Views Baía", Responsible = "Departamento de Eventos" ,  Email = "geral@fourview.pt", ResponsibleContact = "geral@fourview.pt", City = cities[0], EntityType = entityTypes[3]},
                    new Entity() {Name = "Porta 33", Responsible = "Geral" ,  Email = "geral@porta33.pt",  ResponsibleContact = "geral@porta33.pt", City = cities[0], EntityType = entityTypes[2]},
                    new Entity() {Name = "ACIF - Câmara do Comércio e Industria da Madeira", Email = "geral@acif.pt",  Responsible ="Geral" , ResponsibleContact = "geral@acif.pt", City = cities[0], EntityType = entityTypes[4]},
                    new Entity() {Name = "Tasca O Casemiro", Responsible = "Organização de Eventos" ,  Email = "eventos@casemiro.pt", ResponsibleContact = "eventos@casemiro.pt", City = cities[4], EntityType = entityTypes[3]},
                    new Entity() {Name = "Scatt Funchal Jazz Club", Responsible = "Geral" ,  Email = "geral.fx@dolcevita.pt", ResponsibleContact = "geral@scattfunchal.pt", City = cities[0], EntityType = entityTypes[5]},
                    new Entity() {Name = "Dolce Vita Funchal", Responsible = "Geral" ,  Email = "geral.fx@dolcevita.pt",  ResponsibleContact = "geral.fx@dolcevita.pt", City = cities[0], EntityType = entityTypes[3]},
                    new Entity() {Name = "Academia Nova Era", Responsible = "Geral" ,  Email = "geral@ane.pt", ResponsibleContact = "geral@ane.pt", City = cities[0], EntityType = entityTypes[3]},
                    new Entity() {Name = "Centro das Artes - Casa das Mudas", Email = "geral@casadasmudas.pt",  Responsible = "Geral" , ResponsibleContact = "geral@casadasmudas.pt", City = cities[0], EntityType = entityTypes[2]},
                    new Entity() {Name = "Casa do Povo da Boa Ventura", Responsible = "Geral" , Email = "geral@cpbv.pt",  ResponsibleContact = "geral@cpbv.pt", City = cities[5], EntityType = entityTypes[2]},
                    new Entity() {Name = "Casino da Madeira", Responsible = "Gonçalo Abreu" , Email = "gabreu@pestana.pt",  ResponsibleContact = "gabreu@pestana.pt", City = cities[0], EntityType = entityTypes[2]},
                    new Entity() {Name = "IVBAM - Instituto do Vinho, do Bordado e do Artesanato da Madeira", Email= "geral@ivbam.pt", Responsible = "Geral" , ResponsibleContact = "geral@ivbam.pt", City = cities[0], EntityType = entityTypes[2]},     
                    new Entity() {Name = "Associação da Orquestra Clássica da Madeira", Email = "r.correia@aocm.pt",  Responsible = "Rui Correia" , ResponsibleContact = "r.correia@aocm.pt", City = cities[0], EntityType = entityTypes[1]},     
                    new Entity() {Name = "FNAC Madeira", Responsible = "Geral" , Email = "madeira@fnac.pt",  ResponsibleContact = "madeira@fnac.pt", City = cities[0], EntityType = entityTypes[2]},     
                    new Entity() {Name = "Club Naval do Funchal", Responsible = "Geral" , Email = "geral@cnf.pt",  ResponsibleContact = "geral@cnf.pt", City = cities[0], EntityType = entityTypes[2]},     

                };
            entities.ForEach(ent => context.Entities.Add(ent));
            context.SaveChanges();
            #endregion

            #region AUTHENTICATION

            if (!Roles.RoleExists("Administrador do Sistema")) Roles.CreateRole("Administrador do Sistema");
            if (!Roles.RoleExists("Utilizador do Sistema")) Roles.CreateRole("Utilizador do Sistema");
            if (!Roles.RoleExists("Administrador")) Roles.CreateRole("Administrador");
            if (!Roles.RoleExists("Utilizador")) Roles.CreateRole("Utilizador");

            if (!WebSecurity.UserExists("admin@culturam.net"))
                WebSecurity.CreateUserAndAccount("admin@culturam.net", "asd123", new { UserName = "Admin", EntityId = 1 });
            if (!WebSecurity.UserExists("valter@culturam.net"))
                WebSecurity.CreateUserAndAccount("valter@culturam.net", "123456", new { UserName = "Valter Camacho", EntityId = 1 });
            if (!WebSecurity.UserExists("verc04@gmail.com"))
                WebSecurity.CreateUserAndAccount("verc04@gmail.com", "123456", new { UserName = "Edgar Rodrigues", EntityId = 1 });
            if (!WebSecurity.UserExists("virgilio@gmail.com"))
                WebSecurity.CreateUserAndAccount("virgilio@gmail.com", "123456", new { UserName = "Virgílio Caldeira", EntityId = 2 });
            if (!WebSecurity.UserExists("sonia@gmail.com"))
                WebSecurity.CreateUserAndAccount("sonia@gmail.com", "123456", new { UserName = "Sónia Perneta", EntityId = 2 });
            if (!WebSecurity.UserExists("user@gmail.com"))
                WebSecurity.CreateUserAndAccount("user@gmail.com", "123456", new { UserName = "Utilizador", EntityId = 2 });

            if (!Roles.GetRolesForUser("admin@culturam.net").Contains("Administrador do Sistema"))
                Roles.AddUsersToRoles(new[] { "admin@culturam.net" }, new[] { "Administrador do Sistema" });
            if (!Roles.GetRolesForUser("valter@culturam.net").Contains("Administrador do Sistema"))
                Roles.AddUsersToRoles(new[] { "valter@culturam.net" }, new[] { "Administrador do Sistema" });
            if (!Roles.GetRolesForUser("verc04@gmail.com").Contains("Administrador"))
                Roles.AddUsersToRoles(new[] { "verc04@gmail.com" }, new[] { "Administrador" });
            if (!Roles.GetRolesForUser("virgilio@gmail.com").Contains("Administrador"))
                Roles.AddUsersToRoles(new[] { "virgilio@gmail.com" }, new[] { "Administrador" });
            if (!Roles.GetRolesForUser("sonia@gmail.com").Contains("Utilizador"))
                Roles.AddUsersToRoles(new[] { "sonia@gmail.com" }, new[] { "Utilizador" });
            if (!Roles.GetRolesForUser("user@gmail.com").Contains("Utilizador"))
                Roles.AddUsersToRoles(new[] { "user@gmail.com" }, new[] { "Utilizador" });

            #endregion


            #region SAMPLE_DATA

            var weekDays = new List<Tuple<int, string>>
                {
                    new Tuple<int, string>(1, "Domingo"),
                    new Tuple<int, string>(2, "Segunda-feira"),
                    new Tuple<int, string>(3, "Terça-feira"),
                    new Tuple<int, string>(4, "Quarta-feira"),
                    new Tuple<int, string>(5, "Quinta-feira"),
                    new Tuple<int, string>(6, "Sexta-feira"),
                    new Tuple<int, string>(7, "Sábado"),
                };

    
            var eventStates = new List<EventState>
                {
                    new EventState() {State = "Pendente"},
                    new EventState() {State = "Confirmado"},
                    new EventState() {State = "Realizado"},
                    new EventState() {State = "Cancelado"},
                    new EventState() {State = "Adiado"},
                };
            eventStates.ForEach(es => context.EventStates.Add(es));
            context.SaveChanges();


            var accreditingStates = new List<AccreditingState>
                {
                    new AccreditingState() {AccState = "Pendente"},
                    new AccreditingState() {AccState = "Em análise"},
                    new AccreditingState() {AccState = "Aceite"},
                    new AccreditingState() {AccState = "Recusado"},
                };
            accreditingStates.ForEach(accs => context.AccreditingStates.Add(accs));
            context.SaveChanges();


            var targets = new List<Target>
                {
                    new Target() {TargetName = "Infantil"},
                    new Target() {TargetName = "Infanto-Juvenil"},
                    new Target() {TargetName = "Jovenil"},
                    new Target() {TargetName = "Adulto"},
                    new Target() {TargetName = "Idoso"},
                    new Target() {TargetName = "Todos"},
                };
            targets.ForEach(t => context.Targets.Add(t));
            context.SaveChanges();



            var accRequest = new List<AccreditingRequest>
                {
                    new AccreditingRequest() {RequestDate = Convert.ToDateTime("02-06-2015 09:30"), AccreditingState = accreditingStates[2],Entity = entities[0], FeedbackDate = Convert.ToDateTime("02-06-2015 09:30"), RequestCode = "DKRET1", UserProfile = context.UserProfiles.First(x => x.UserId == 1)},
                    new AccreditingRequest() {RequestDate = Convert.ToDateTime("21-06-2015 15:45"), AccreditingState = accreditingStates[1],Entity = entities[3], FeedbackDate = Convert.ToDateTime("21-06-2015 15:45"), RequestCode = "BDCMP2", UserProfile = context.UserProfiles.First(x => x.UserId == 1)},
                    new AccreditingRequest() {RequestDate = Convert.ToDateTime("05-07-2015 09:30"), AccreditingState = accreditingStates[3],Entity = entities[5], FeedbackDate = Convert.ToDateTime("05-07-2015 09:30"), RequestCode = "PSNVD3", UserProfile = context.UserProfiles.First(x => x.UserId == 1)},
                    new AccreditingRequest() {RequestDate = Convert.ToDateTime("12-07-2015 09:30"), AccreditingState = accreditingStates[2],Entity = entities[1], FeedbackDate = Convert.ToDateTime("12-07-2015 09:30"), RequestCode = "TRLVD7", UserProfile = context.UserProfiles.First(x => x.UserId == 4)},
                };
            accRequest.ForEach(ar => context.AccreditingRequests.Add(ar));
            context.SaveChanges();


            var eventTypes = new List<EventType>
                {
                    new EventType() {Type = "Genérico", Color ="#002030"},
                    new EventType() {Type = "Cultural", Color ="#404479"},
                    new EventType() {Type = "Música", Color ="#794044"},
                    new EventType() {Type = "Dança", Color ="#b4155d"},
                    new EventType() {Type = "Desporto", Color ="#cd3700"},
                    new EventType() {Type = "Religião", Color ="#6b441c"},
                    new EventType() {Type = "Teatro", Color ="#631ea2"},
                    new EventType() {Type = "Exposição", Color ="#008000"},
                    new EventType() {Type = "Visita Guiada", Color ="#39697e"},
                    new EventType() {Type = "Espectáculo", Color ="#313131"},
                    new EventType() {Type = "Workshop/Palestra", Color ="#ff8000"},
                    new EventType() {Type = "Cinema", Color ="#ffd700"},
                    new EventType() {Type = "Apresentação", Color ="#e5b451"},
                    new EventType() {Type = "Concurso", Color ="#f0cebb"},

                };
            eventTypes.ForEach(et => context.EventTypes.Add(et));
            context.SaveChanges();

            eventTypes[0].SuperType = null;
            eventTypes[1].SuperType = eventTypes[0];
            eventTypes[2].SuperType = eventTypes[1];
            eventTypes[3].SuperType = eventTypes[1];
            eventTypes[4].SuperType = eventTypes[0];
            eventTypes[5].SuperType = eventTypes[0];
            eventTypes[6].SuperType = eventTypes[0];
            eventTypes[7].SuperType = eventTypes[1];
            eventTypes[8].SuperType = eventTypes[0];
            eventTypes[9].SuperType = eventTypes[1];
            eventTypes[10].SuperType = eventTypes[0];
            eventTypes[11].SuperType = eventTypes[2];
            eventTypes[12].SuperType = eventTypes[0];
            eventTypes[13].SuperType = eventTypes[0];

            context.SaveChanges();


            var genericProperties = new List<EventProperty>
                {
                    new EventProperty() {Name = "Estado", Mandatory = true, DefaultValue = "1", Kind = "Lista", Values = new SelectList(eventStates.ToList(),"StateId","State",0)},
                    new EventProperty() {Name = "Local", Mandatory = true, DefaultValue = "", Kind = "Lista", Values = new SelectList(cities.ToList(),"CityId","CityName",0)},
                    new EventProperty() {Name = "Dia da Semana", Mandatory = true, DefaultValue = "", Kind = "Lista", Values = new SelectList(weekDays.ToList(),"Item1","Item2",0)},
                    new EventProperty() {Name = "Preço", Mandatory = true, DefaultValue = "Gratuito", Kind = "Texto"},
                    new EventProperty() {Name = "Sinopse", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Origem", Mandatory = false, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Público-alvo", Mandatory = false, DefaultValue = "Todos", Kind = "Lista", Values = new SelectList(targets.ToList(),"TargetId","TargetName",0)},
                    new EventProperty() {Name = "Notas", Mandatory = false, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Informações", Mandatory = false, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Ativo", Mandatory = true, DefaultValue = "Sim", Kind = "Sim/Não"},
                    new EventProperty() {Name = "Destaque", Mandatory = true, DefaultValue = "Não", Kind = "Sim/Não"},
                    new EventProperty() {Name = "Público", Mandatory = true, DefaultValue = "Não", Kind = "Sim/Não"},

                };
            genericProperties.ForEach(ep => context.EventProperties.Add(ep));
            context.SaveChanges();

            var culturalProperties = new List<EventProperty>
                {
                    new EventProperty() {Name = "Prop. Cultura 1", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Prop. Cultura 2", Mandatory = true, DefaultValue = "", Kind = "Número"},
                };
            culturalProperties.ForEach(ep => context.EventProperties.Add(ep));
            context.SaveChanges();

            var musicProperties = new List<EventProperty>
                {
                    new EventProperty() {Name = "Prop. Música 1", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Prop. Música 2", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Prop. Música 3", Mandatory = true, DefaultValue = "", Kind = "Número"},
                };
            musicProperties.ForEach(ep => context.EventProperties.Add(ep));
            context.SaveChanges();

            var danceProperties = new List<EventProperty>
                {
                    new EventProperty() {Name = "Prop. Dança 1", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Prop. Dança 2", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                    new EventProperty() {Name = "Prop. Dança 3", Mandatory = true, DefaultValue = "", Kind = "Texto"},
                };
            danceProperties.ForEach(ep => context.EventProperties.Add(ep));
            context.SaveChanges();

            eventTypes[0].EventProperties = genericProperties;
            eventTypes[1].EventProperties = culturalProperties;
            eventTypes[2].EventProperties = musicProperties;
            eventTypes[3].EventProperties = danceProperties;
            context.SaveChanges();

            var places = new List<Place>
                {
                    new Place() {NamePlace = "Casino da Madeira", City = cities[2], Coordinates = "32.643855,-16.916542"},
                    new Place() {NamePlace = "Madeira Tecnopolo", City = cities[2], Coordinates = "32.659962,-16.9261"},
                    new Place() {NamePlace = "Jardim Municipal", City = cities[2], Coordinates = "32.647516,-16.9113319"},
                    new Place() {NamePlace = "Museu de Electricidade Casa da Luz", City = cities[2], Coordinates = "32.646914,-16.903862"},
                    new Place() {NamePlace = "Teatro Municipal Baltazer Dias", City = cities[2], Coordinates = "32.646982,-16.911424"},
                    new Place() {NamePlace = "Salão Nobre da Câmara Municipal do Funchal", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Auditório do Centro Cívico do Estreito", City = cities[1], Coordinates = ""},
                    new Place() {NamePlace = "FNAC Madeira", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Complexo Desportivo da Nazaré", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Colégio dos Jesuítas", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Reids Palace Hotel", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Malo Clinic", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Átrio do Museu Etnográfico da Madeira", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Auditório do Museu de Imprensa da Madeira", City = cities[1], Coordinates = "32.6490569,-16.9780938"},
                    new Place() {NamePlace = "MadeiraShopping", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Café do Teatro", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Auditório da Casa-Museu Frederico de Freitas", City = cities[2]},
                    new Place() {NamePlace = "Auditório da ACIF", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Tasca O Casemiro", City = cities[4], Coordinates = ""},
                    new Place() {NamePlace = "Scatt Funchal Jazz Club", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Dolce Vita Funchal", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Academia Nova Era", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Galeria Casa das Mudas", City = cities[0], Coordinates = "32.723032,-17.180514"},
                    new Place() {NamePlace = "Casa do Povo da Boa Ventura", City = cities[5], Coordinates = ""},
                    new Place() {NamePlace = "Instituto do Vinho", City = cities[2], Coordinates = ""},
                    new Place() {NamePlace = "Igreja Inglesa", City = cities[2], Coordinates = ""},
   
                };
            places.ForEach(p => context.Places.Add(p));
            context.SaveChanges();

            #region EVENTS LIST
            var events = new List<Event>
                {
                    new Event() //events[0]
                    {
                        Title = "P.I. Tchaikovsky - Concerto para violino e orquestra",
                        StartDate = Convert.ToDateTime("01-07-2015 18:00"), 
                        EndDate = Convert.ToDateTime("01-07-2015 18:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/1/Img/1.jpg",
                        //Place = places[0],
                        Entity = entities[4],
                    }, 
                    new Event() //events[1]
                    {
                        Title = "Concerto Comemorativo do 49º aniversário da AOCM",
                        StartDate = Convert.ToDateTime("02-06-2015 21:00"), 
                        EndDate = Convert.ToDateTime("02-06-2015 21:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/2/Img/2.jpg",
                        //Place = places[0],
                        Entity = entities[30],
                    }, 
                    new Event() //events[2]
                    {
                        Title = "Ciclo de Concertos com o grupo 'Sonho de Orpheu'",
                        StartDate = Convert.ToDateTime("30-05-2015"),
                        EndDate = Convert.ToDateTime("30-05-2015"), 
                        Duration = "1 ano",
                        EventType = eventTypes[2],
                        Public = true,
                        Poster = "/Content/Event/3/Img/3.jpg",
                        //Place = places[0],
                        Entity = entities[30],
                    },

                    new Event() //events[3]
                    {
                        Title = "Oficina de Teatro - Artes Performativas",
                        StartDate = Convert.ToDateTime("28-05-2015 09:30"), 
                        EndDate = Convert.ToDateTime("08-06-2015 09:30"), 
                        Duration = "5 meses",
                        EventType = eventTypes[6],
                        Public = false,
                        Poster = "/Content/Event/4/Img/4.jpg",
                        //Place = places[0],
                        Entity = entities[11],
                    },
                    new Event() //events[4]
                    {
                        Title = "Ruralidade Madeirense",
                        StartDate = Convert.ToDateTime("23-06-2015 18:00"), 
                        EndDate = Convert.ToDateTime("23-06-2015 18:00"),
                        Duration = "1 hora",
                        EventType = eventTypes[7],
                        Public = false,
                        Poster = "/Content/Event/5/Img/5.jpg",
                        //Place = places[0],
                        Entity = entities[31], 
                    },

                    new Event() //events[5]
                    {
                        Title = "III Torneio Solidário de Basquetebol Auático 2015",
                        StartDate = Convert.ToDateTime("29-07-2015 09:00"), 
                        EndDate = Convert.ToDateTime("29-07-2015 09:00"), 
                        Duration = "",
                        EventType = eventTypes[4],
                        Public = false,
                        Poster = "/Content/Event/6/Img/6.jpg",
                        //Place = places[0],
                        Entity = entities[32], 
                    }, 
                    new Event() //events[6]
                    {
                        Title = "Visitas guiadas ao interior do Colégio dos Jesuítas",
                        StartDate = Convert.ToDateTime("28-05-2015"), 
                        EndDate = Convert.ToDateTime("30-05-2015"), 
                        Duration = "",
                        EventType = eventTypes[8],
                        Public = true,
                        Poster = "/Content/Event/7/Img/7.png",
                        //Place = places[0],
                        Entity = entities[12], 
                    }, 
                    new Event() //events[7]
                    {
                        Title = "Espetáculo Solidário pelo Porto da Cruz",
                        StartDate = Convert.ToDateTime("09-06-2015 18:30"), 
                        EndDate = Convert.ToDateTime("09-06-2015 18:30"), 
                        Duration = "",
                        EventType = eventTypes[9],
                        Public = false,
                        Poster = "/Content/Event/8/Img/8.jpg",
                        //Place = places[0],
                        Entity = entities[10], 
                    }, 
                    new Event() //events[8]
                    {
                        Title = "Música de Câmara",
                        StartDate = Convert.ToDateTime("07-06-2015 21:30"), 
                        EndDate = Convert.ToDateTime("07-06-2015 21:30"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = true,
                        Poster = "/Content/Event/9/Img/9.jpg",
                        //Place = places[0],
                        Entity = entities[4], 
                    },
                    new Event() //events[9]
                    {
                        Title = "Educação das Emoções",
                        StartDate = Convert.ToDateTime("15-06-2015 18:30"), 
                        EndDate = Convert.ToDateTime("15-06-2015 18:30"), 
                        Duration = "",
                        EventType = eventTypes[10],
                        Public = false,
                        Poster = "/Content/Event/10/Img/10.jpg",
                        //Place = places[0],
                        Entity = entities[14], 
                    },
                    new Event() //events[10]
                    {
                        Title = "Embalagens de conservação e transporte: As caixas de folha-de-flandres",
                        StartDate = Convert.ToDateTime("27-05-2015"), 
                        EndDate = Convert.ToDateTime("26-05-2015"), 
                        Duration = "",
                        EventType = eventTypes[7],
                        Public = false,
                        Poster = "/Content/Event/11/Img/11.jpg",
                        //Place = places[0],
                        Entity = entities[15], 
                    },

                    new Event() //events[11]
                    {
                        Title = "Inauguração da Exposição 'Santa Liberdade 1961'",
                        StartDate = Convert.ToDateTime("22-06-2015 17:30"),
                        EndDate = Convert.ToDateTime("22-06-2015 17:30"), 
                        Duration = "",
                        EventType = eventTypes[7],
                        Public = false,
                        Poster = "/Content/Event/12/Img/12.png",
                        //Place = places[0],
                        Entity = entities[16], 
                    }, 
                    new Event() //events[12]
                    {
                        Title = "Silence 4 na Praça do Mar",
                        StartDate = Convert.ToDateTime("22-07-2015"),
                        EndDate = Convert.ToDateTime("23-07-2015"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/13/Img/13.jpg",
                        //Place = places[0],
                        Entity = entities[0], 
                    }, 
                    new Event() //events[13]
                    {
                        Title = "Cinema Português Contemporâneo",
                        StartDate = Convert.ToDateTime("05-08-2015"),
                        EndDate = Convert.ToDateTime("08-08-2015"),
                        Duration = "",
                        EventType = eventTypes[11],
                        Public = false,
                        Poster = "/Content/Event/14/Img/14.png",
                        //Place = places[0],
                        Entity = entities[12], 
                    }, 

                    new Event() //events[14]
                    {
                        Title = "Exposição de Bicicletas Antigas",
                        StartDate = Convert.ToDateTime("29-06-2015"),
                        EndDate = Convert.ToDateTime("02-07-2015"), 
                        Duration = "",
                        EventType = eventTypes[7],
                        Public = false,
                        Poster = "/Content/Event/15/Img/15.jpg",
                        //Place = places[0],
                        Entity = entities[17], 
                    }, 

                    new Event() //events[15]
                    {
                        Title = "DJ YVES V no Café do Teatro",
                        StartDate = Convert.ToDateTime("22-07-2015"),
                        EndDate = Convert.ToDateTime("22-07-2015"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = true,
                        Poster = "/Content/Event/16/Img/16.jpg",
                        //Place = places[0],
                        Entity = entities[18], 
                    }, 
                    new Event() //events[16]
                    {
                        Title = "Zenitudes",
                        StartDate = Convert.ToDateTime("08-08-2015 10:00"),
                        EndDate = Convert.ToDateTime("08-08-2015 10:00"), 
                        Duration = "",
                        EventType = eventTypes[10],
                        Public = true,
                        Poster = "/Content/Event/17/Img/17.jpg",
                        //Place = places[0],
                        Entity = entities[19], 
                    }, 
                    new Event() //events[17]
                    {
                        Title = "Apresentação do DVD 'O amor que purifica e Trotoário azul'",
                        StartDate = Convert.ToDateTime("07-07-2015 10:00"),
                        EndDate = Convert.ToDateTime("07-07-2015 10:00"), 
                        Duration = "",
                        EventType = eventTypes[12],
                        Public = false,
                        Poster = "/Content/Event/18/Img/18.png",
                        //Place = places[0],
                        Entity = entities[20], 
                    }, 
                    new Event() //events[18]
                    {
                        Title = "Concurso - Funchal Noivos & Festas",
                        StartDate = Convert.ToDateTime("05-07-2015"),
                        EndDate = Convert.ToDateTime("28-07-2015"), 
                        Duration = "",
                        EventType = eventTypes[1],
                        Public = false,
                        Poster = "/Content/Event/19/Img/19.png",
                        //Place = places[0],
                        Entity = entities[0], 
                    }, 
                    new Event() //events[19]
                    {
                        Title = "Ciclo de Conferências: 'O poder da Imprensa'",
                        StartDate = Convert.ToDateTime("17-06-2015 16:00"),
                        EndDate = Convert.ToDateTime("17-06-2015 16:00"), 
                        Duration = "",
                        EventType = eventTypes[13],
                        Public = false,
                        Poster = "/Content/Event/20/Img/20.png",
                        //Place = places[0],
                        Entity = entities[21], 
                    }, 

                    new Event() //events[20]
                    {
                        Title = "Tasca 'O Casimiro' - Somos o q' Sentimos",
                        StartDate = Convert.ToDateTime("28-06-2015 22:00"),
                        EndDate = Convert.ToDateTime("28-06-2015 22:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/21/Img/21.jpg",
                        //Place = places[0],
                        Entity = entities[22], 
                    }, 
                    new Event() //events[21]
                    {
                        Title = "André Sarbib no SCAT",
                        StartDate = Convert.ToDateTime("07-07-2015"),
                        EndDate = Convert.ToDateTime("08-07-2015"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/22/Img/22.jpg",
                        //Place = places[0],
                        Entity = entities[23], 
                    }, 
                    new Event() //events[22]
                    {
                        Title = "Demonstração e Experimentação de Esgrima",
                        StartDate = Convert.ToDateTime("05-08-2015"),
                        EndDate = Convert.ToDateTime("05-08-2015"), 
                        Duration = "",
                        EventType = eventTypes[4],
                        Public = false,
                        Poster = "/Content/Event/23/Img/23.jpg",
                        //Place = places[0],
                        Entity = entities[32], 
                    }, 
                    new Event() //events[23]
                    {
                        Title = "Workshop da Academia Nova Era",
                        StartDate = Convert.ToDateTime("19-07-2015 09:00"),
                        EndDate = Convert.ToDateTime("26-07-2015 9:00"), 
                        Duration = "9 meses",
                        EventType = eventTypes[10],
                        Public = true,
                        Poster = "/Content/Event/24/Img/24.jpg",
                        //Place = places[0],
                        Entity = entities[25], 
                    }, 

                    new Event() //events[24]
                    {
                        Title = "The Vast and Meaninggful V06-2015",
                        StartDate = Convert.ToDateTime("25-06-2015"), 
                        EndDate = Convert.ToDateTime("25-06-2015"), 
                        Duration = "",
                        EventType = eventTypes[7],
                        Public = false,
                        Poster = "/Content/Event/25/Img/25.jpg",
                        //Place = places[0],
                        Entity = entities[26], 
                    },
                    new Event() //events[25]
                    {
                        Title = "Ensemble de Clarinetes da DRE/Educação Artísica e Grupo Coral e Instrumental da Ponta do Sol",
                        StartDate = Convert.ToDateTime("01-07-2015 20:30"),
                        EndDate = Convert.ToDateTime("01-07-2015 20:30"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = true,
                        Poster = "/Content/Event/26/Img/26.jpg",
                        //Place = places[0],
                        Entity = entities[1], 
                    },
                    new Event() //events[26]
                    {
                        Title = "Ensemble de Cordas da DRE/Educação Artística",
                        StartDate = Convert.ToDateTime("20-07-2015 16:00"),
                        EndDate = Convert.ToDateTime("20-07-2015 16:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/27/Img/27.jpg",
                        //Place = places[0],
                        Entity = entities[1], 
                    },
                    new Event() //events[27]
                    {
                        Title = "L. van Beethoven - Sinfonia nº 7 em Lá maior Op.92",
                        StartDate = Convert.ToDateTime("09-05-2015 21:00"),
                        EndDate = Convert.ToDateTime("09-05-2015 21:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/28/Img/28.jpg",
                        //Place = places[0],
                        Entity = entities[4], 
                    },  
                    new Event() //[28]
                    {
                        Title = "Sons da Adega",
                        StartDate = Convert.ToDateTime("14-05-2015 21:00"),
                        EndDate = Convert.ToDateTime("14-05-2015 21:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/29/Img/29.jpg",
                        //Place = places[0],
                        Entity = entities[1], 
                    },
                    new Event() //events[29]
                    {
                        Title = "Concerto da Orquestra de Bandolins da Madeira",
                        StartDate = Convert.ToDateTime("14-06-2015 21:00"),
                        EndDate = Convert.ToDateTime("14-06-2015 21:00"), 
                        Duration = "",
                        EventType = eventTypes[2],
                        Public = false,
                        Poster = "/Content/Event/30/Img/30.jpg",
                        //Place = places[0],
                        Entity = entities[2], 
                    },
                };

            events.ForEach(ev => context.Events.Add(ev));
            context.SaveChanges();
            #endregion

            events[0].EventType = eventTypes[1];
            events[1].EventType = eventTypes[2];

            var eventProps0 = new List<EventPropertyValue>
                {
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[0], Value = eventStates[2].State},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[1], Value = places[6].NamePlace},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[2], Value = "Segunda-feira"},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[3], Value = "5€"},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[8], Value = "Informações..."},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[9], Value = "Sim"},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[10], Value = "Sim"},
                    new EventPropertyValue() { Event = events[0], EventProperty = genericProperties[6], Value = targets[3].TargetName}
                };
            eventProps0.ForEach(eval11 => context.EventPropertyValues.Add(eval11));
            context.SaveChanges();

            var eventProps1 = new List<EventPropertyValue>
                {
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[0], Value = eventStates[2].State},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[1], Value = places[6].NamePlace},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[2], Value = "Segunda-feira"},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[3], Value = "5€"},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[8], Value = "Informações..."},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[9], Value = "Sim"},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[10], Value = "Sim"},
                    new EventPropertyValue() { Event = events[1], EventProperty = genericProperties[6], Value = targets[3].TargetName}
                };
            eventProps1.ForEach(eval1 => context.EventPropertyValues.Add(eval1));
            context.SaveChanges();

            context.EventPropertyValues.Add(
                    new EventPropertyValue() { Event = events[7], EventProperty = genericProperties[1], Value = places[5].NamePlace });
            context.EventPropertyValues.Add(
                    new EventPropertyValue() { Event = events[2], EventProperty = genericProperties[1], Value = places[2].NamePlace });
            context.EventPropertyValues.Add(
                    new EventPropertyValue() { Event = events[3], EventProperty = genericProperties[1], Value = places[4].NamePlace });
            context.EventPropertyValues.Add(
                    new EventPropertyValue() { Event = events[4], EventProperty = genericProperties[1], Value = places[11].NamePlace });
            context.EventPropertyValues.Add(
                    new EventPropertyValue() { Event = events[5], EventProperty = genericProperties[1], Value = places[15].NamePlace });
            context.EventPropertyValues.Add(
                    new EventPropertyValue() { Event = events[6], EventProperty = genericProperties[1], Value = places[9].NamePlace });
            context.SaveChanges();


            var eventProps17 = new List<EventPropertyValue>
                {             
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[0], Value = eventStates[3].State},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[1], Value = places[1].NamePlace},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[2], Value = "Sábado"},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[3], Value = "10€"},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[8], Value = "O evento..."},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[9], Value = "Sim"},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[10], Value = "Sim"},
                    new EventPropertyValue() { Event = events[17], EventProperty = genericProperties[6], Value = targets[5].TargetName}
                };
            eventProps17.ForEach(eval17 => context.EventPropertyValues.Add(eval17));
            context.SaveChanges();

            var eventProps23 = new List<EventPropertyValue>
                {             
                    new EventPropertyValue() { Event = events[23], EventProperty = genericProperties[0], Value = eventStates[2].State},
                    new EventPropertyValue() { Event = events[23], EventProperty = genericProperties[1], Value = places[2].NamePlace},
                    new EventPropertyValue() { Event = events[23], EventProperty = genericProperties[2], Value = "Gratuito"},
                    new EventPropertyValue() { Event = events[23], EventProperty = genericProperties[9], Value = "Não"},
                    new EventPropertyValue() { Event = events[23], EventProperty = genericProperties[10], Value = "Sim"},
                    new EventPropertyValue() { Event = events[23], EventProperty = genericProperties[6], Value = targets[4].TargetName}
                };
            eventProps23.ForEach(eval23 => context.EventPropertyValues.Add(eval23));
            context.SaveChanges();

            var eventProps25 = new List<EventPropertyValue>
                {             
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[0], Value = eventStates[0].State},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[1], Value = places[4].NamePlace},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[2], Value = "Domingo"},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[3], Value = "Gratuito"},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[8], Value = "Sim"},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[9], Value = "Não"},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[10], Value = "Sim"},
                    new EventPropertyValue() { Event = events[25], EventProperty = genericProperties[6], Value = targets[5].TargetName}
                };
            eventProps25.ForEach(eval25 => context.EventPropertyValues.Add(eval25));
            context.SaveChanges();

            var eventProps14 = new List<EventPropertyValue>
                {           
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[0], Value = eventStates[2].State},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[1], Value = places[3].NamePlace},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[2], Value = "Domingo"},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[3], Value = "20€"},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[8], Value = "Este evento é..."},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[9], Value = "Não"},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[10], Value = "Sim"},
                    new EventPropertyValue() { Event = events[14], EventProperty = genericProperties[6], Value = targets[5].TargetName}
                };
            eventProps14.ForEach(eval14 => context.EventPropertyValues.Add(eval14));
            context.SaveChanges();

            var eventProps9 = new List<EventPropertyValue>
                {
                    new EventPropertyValue() {Event = events[9], EventProperty = genericProperties[10], Value = "Sim"},
                };
            eventProps9.ForEach(eval9 => context.EventPropertyValues.Add(eval9));
            context.SaveChanges();

            var eventProps15 = new List<EventPropertyValue>
                {
                    new EventPropertyValue() {Event = events[15], EventProperty = genericProperties[10], Value = "Sim"},
                };
            eventProps15.ForEach(eval15 => context.EventPropertyValues.Add(eval15));
            context.SaveChanges();

            var eventProps18 = new List<EventPropertyValue>
                {
                    new EventPropertyValue() {Event = events[18], EventProperty = genericProperties[10], Value = "Sim"},
                };
            eventProps18.ForEach(eval18 => context.EventPropertyValues.Add(eval18));
            context.SaveChanges();

            //events[0].PropertyValues = eventProps0;
            //events[9].PropertyValues = eventProps9;
            //events[14].PropertyValues = eventProps14;
            //events[15].PropertyValues = eventProps15;
            //events[17].PropertyValues = eventProps17;
            //events[18].PropertyValues = eventProps18;
            //events[23].PropertyValues = eventProps23;
            //events[25].PropertyValues = eventProps25;
            context.SaveChanges();


            var sessions0 = new List<Session>
                {
                    new Session() {Title = "Crianças", Duration = "30", Date = Convert.ToDateTime("27-07-2013 09:00"), Price = "5€", Place = places[2], Event = events[0]},
                    new Session() {Title = "Adultos", Duration = "30", Date = Convert.ToDateTime("27-07-2013 09:00"), Price = "10€", Place = places[2], Event = events[0]},
                };
            sessions0.ForEach(s => context.Sessions.Add(s));
            context.SaveChanges();


            var sessions1 = new List<Session>{  
                    new Session() {Title = "Dia 1", Duration = "90", Date = Convert.ToDateTime("29-07-2013 19:00"), Place = places[0], Event = events[1]},
                    new Session() {Title = "Dia 2", Duration = "50", Date = Convert.ToDateTime("30-07-2013 20:00"), Place = places[1], Event = events[1]},
                    new Session() {Title = "Dia 3", Duration = "30", Date = Convert.ToDateTime("31-07-2013 18:00"), Place = places[3], Event = events[1]},
                };

            sessions1.ForEach(s => context.Sessions.Add(s));
            context.SaveChanges();

            events[0].EventSessions = sessions0;
            events[1].EventSessions = sessions1;
            context.SaveChanges();


            var participTypes = new List<ParticipantType>
                {
                    new ParticipantType() {ParticipType = "Individual"},
                    new ParticipantType() {ParticipType = "Grupo"},
                    
                };
            participTypes.ForEach(pt => context.ParticipantTypes.Add(pt));
            context.SaveChanges();

            var participants = new List<Participant>
                {
                    new Participant() {Name = "Vânia Fernandes", ParticipantType = participTypes[0], Curriculum = "sem curriculo", Photo = "sem foto", Active = true},
                    new Participant() {Name = "Banda da Além", ParticipantType = participTypes[1], Curriculum = "Fundado em...", Photo = "sem foto", Active = false},
                    new Participant() {Name = "Xarabanda", ParticipantType = participTypes[1], Curriculum = "Foi constituido em...", Photo = "sem foto", Active = true},
                };
            participants.ForEach(p => context.Participants.Add(p));
            context.SaveChanges();

            var eventParticip = new List<EventParticipant>
                {
                    new EventParticipant() {Event = events[0], Participant = participants[0]},
                    new EventParticipant() {Event = events[0], Participant = participants[1]},
                    new EventParticipant() {Event = events[0], Participant = participants[2]},
                    new EventParticipant() {Event = events[1], Participant = participants[2]}
                };
            eventParticip.ForEach(ep => context.EventParticipants.Add(ep));
            context.SaveChanges();

            events[0].EventParticipants.Add(eventParticip[0]);
            events[0].EventParticipants.Add(eventParticip[1]);
            events[0].EventParticipants.Add(eventParticip[2]);
            events[1].EventParticipants.Add(eventParticip[3]);
            context.SaveChanges();

            participants[0].EventParticipants.Add(eventParticip[0]);
            participants[1].EventParticipants.Add(eventParticip[1]);
            participants[2].EventParticipants.Add(eventParticip[2]);
            participants[2].EventParticipants.Add(eventParticip[3]);
            context.SaveChanges();


            var resourceTypes = new List<ResourceType>
                {
                    new ResourceType() {ResType = "Imagem"},
                    new ResourceType() {ResType = "Vídeo"},
                    new ResourceType() {ResType = "Documento"}
                    
                };
            resourceTypes.ForEach(rt => context.ResourceTypes.Add(rt));
            context.SaveChanges();


            var resources = new List<Resource>
                {
                    new Resource() {ResourceType = resourceTypes[0], Name = "Foto do Grupo", File = "Event/2/Resources/img_01.jpg", Event = events[1]},
                    new Resource() {ResourceType = resourceTypes[1], Name = "Spot de Divulgação", File = "Event/2/Resources/vid_01.mpg", Event = events[1]},
                    new Resource() {ResourceType = resourceTypes[2], Name = "Programa", File = "Event/2/Resources/doc_01.pdf", Event = events[1]},
                };
            resources.ForEach(r => context.Resources.Add(r));
            context.SaveChanges();

            events[1].Resources = resources;
            context.SaveChanges();


            var comments = new List<Comment>
                {
                    new Comment() {Name = "José", Date = Convert.ToDateTime("01-03-2015 11:42:20"), CommentText = "Gostei do espectáculo.", Event = events[0]},
                    new Comment() {Name = "Maria", Date = Convert.ToDateTime("14-04-2015 19:27:21"), CommentText = "Evento a não perder!", Event = events[0]},
                    new Comment() {Name = "António", Date = Convert.ToDateTime("22-04-2015 16:04:31"), CommentText = "Exelente atuação.", Event = events[0]},
                };
            comments.ForEach(r => context.Comments.Add(r));
            context.SaveChanges();

            //var responses = new List<Comment>
            //    {
            //        new Comment() {Name = "Manuel", CommentText = "Também gostei muito.", Event = events[1]},
            //        new Comment() {Name = "Rui", CommentText = "Sem dúvida!", Event = events[1]},
            //        new Comment() {Name = "Marta", CommentText = "Exelente mesmo.", Event = events[1]}
            //    };
            //responses.ForEach(r => context.Comments.Add(r));
            //context.SaveChanges();

            //comments[0].Responses.Add(responses[0]);
            //comments[1].Responses.Add(responses[1]);
            //comments[2].Responses.Add(responses[2]);
            //context.SaveChanges();

            #endregion
        }
    }
}